package org.alis.smallcc.designpatterns.behavior.mediator;

/**
 * lowser
 * 
 * @author: luochuan     
 * @date: 2020年12月28日 下午5:34:30
 */
public class LowColleague  implements Colleague{

	private String name;
	
	private Mediator mediator;
	
	public LowColleague(String name,Mediator mediator) {
		this.name = name;
		this.mediator = mediator;
		register();
	}
	
	@Override
	public void send(Message message) {
		message.setMessageBody(name+" lower:"+message.getMessageBody());
		mediator.forward(this, message);
	}

	@Override
	public void handlerMessage(Message message) {
		System.out.println(name + " lower handler this type message: "+message.getMessageType()+","+message.getMessageBody().replace("send one message", ""));
	}

	@Override
	public void register() {
		this.mediator.register(this);
	}

}
